import request from "./request"
//登录
export const login = (form) => request.post('login', form)

//左侧菜单
export const getMenus = () => request.get('menus')

/**
 * 
 * @returns 用户管理
 */
//用户管理
export const getUsers = (form) => request.get('users', { params: form })

//删除
export const getDelete = (id) => request.delete(`users/${id}`)

//添加
export const addUser = (model) => request.post('users', model)

//修改
export const getEdit = (id, model) => request.put(`users/${id}`, model)

//修改状态
export const getSwitch = (id, state) => request.put(`users/${id}/state/${state}`)


/**
 * 
 * @returns 角色管理
 */
//获取角色列表
export const getRole = () => request.get(`roles`)

//获取角色
export const updateRole = (id, rid) => request.put(`users/${id}/role`, { rid })

/**
 * 
 * @returns 权限列表
 */
//权限
export const getRight = () => request.get('/rights/list')

//角色列表
export const getRoles = () => request.get('/roles')

//添加角色
export const addRoles = (form) => request.post('/roles', form)

//删除角色
export const roleDelete = (id) => request.delete(`roles/${id}`)

//修改角色
export const editRole = (id, form) => request.put(`roles/${id}`, form)

//获取权限
export const getRightsTree = (roleId, rids) => request.post(`roles/${roleId}/rights`, rids)

//获取树形数据
export const getTree = () => request.get('/rights/tree')

//删除权限
export const delRightes = (roleId, rightId) => request.delete(`/roles/${roleId}/rights/${rightId}`)

/**
 * 
 * @returns 商品分类
 */
//获取商品分类数据
export const getCateList = (form) => request.get(`categories`, { params: form })

//获取父级级联选择器
export const goodsfu = () => request.get(`categories`, { params: { type: 2 } })

//添加分类
export const getCate = (form) => request.post(`categories`, form)

//编辑
export const CateEdit = (form) => request.put(`categories/${form.cat_id}`, form)

//删除
export const CateDel = (id) => request.delete(`categories/${id}`)

/**
 * 商品参数
 */
//获取级联框分类的数据
export const getParams = () => request.get('categories')

//获取参数列表
export const getParamsList = (id, type) => request.get(`categories/${id}/attributes?sel=${type}`)

//添加动态参数或静态属性
export const addParamsList = (id, model) => request.post(`categories/${id}/attributes`, model)

//修改参数
export const Editparams = (id, form) => request.put(`categories/${id}/attributes/${form.attr_id}`, form)

//删除删除
export const deleParams = (id, attrid) => request.delete(`categories/${id}/attributes/${attrid}`)

//添加tag数据
export const TagList = (id, attrId, model) => request.put(`categories/${id}/attributes/${attrId}`, model)

/**
 * 商品列表
 */
export const getGoods = (model) => request.get('goods', { params: model })

//删除
export const GoodsDelete = (id) => request.delete(`goods/${id}`)

//获取所有分类数据
export const Goodscate = () => request.get('categories')

//添加
export const getNewGoods = (form) => request.post('goods', form)

//数据图
export const reportd=()=>request.get('reports/type/1')

